#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <deque>
#include <set>
#include <map> 

#define flr(x, l, r) for (int x = l; x <= r; ++x)
#define frl(x, r, l) for (int x = r; x >= l; --x)
#define fmp(x, t) for (int x = h[t]; ~x; x = ne[x])
#define LL long long
#define mt memset
#define my memcpy
#define szf sizeof
#define INF 0x3f3f3f3f
#define in(x) scanf("%d", &x)
#define out(x) printf("%d", x)
#define inll(x) scanf("%lld", &x)
#define outll(x) printf("%lld", x)
#define pn printf("\n")
#define con continue
#define bk break
#define vc vector
#define pb push_back
#define sz size
#define PII pair<int, int>
#define x first
#define y second
#define P_q priority_queue
#define ft front
#define pf push_front
#define popf pop_front
#define it insert
#define ct count

using namespace std;

const int N = 10010, M = 2 * N;

int n, m;
int h[N], e[M], ne[M], w[M], idx;
int dist[N];
int p[N];
int res[M];
vc<PII> query[N];
int st[N];

void add(int a,int b, int c) {
    e[idx] = b, w[idx] = c, ne[idx] = h[a], h[a] = idx ++ ;
}

void dfs(int u, int fa) {
    fmp (i, u) {
        int j = e[i];
        if (j == fa) con;
        dist[j] = dist[u] + w[i];
        dfs(j, u);
    }
}

int find(int x) {
    if (p[x] != x) p[x] = find(p[x]);
    return p[x];
}

void tarjan(int u) {
    st[u] = 1;
    fmp (i, u) {
        int j = e[i];
        if (!st[j]) {
            tarjan(j);
            p[j] = u;
        }
    }
    
    for (auto item : query[u]) {
        int num = item.x, id = item.y;
        if (st[num] == 2) {
            int anc = find(num);
            res[id] = dist[u] + dist[num] - 2 * dist[anc];
        }
    }
    
    st[u] = 2;
}

int main() {
	in(n), in(m);
	
	mt(h, -1, szf h);
	flr (i, 1, n - 1) {
	    int a, b, c;
	    in(a), in(b), in(c);
	    add(a, b, c), add(b, a, c);
	}
    
    flr (i, 0, m - 1) {
        int a, b;
        in(a), in(b);
        if (a != b) {
            query[a].pb({b, i});
            query[b].pb({a, i});
        }
    }
    
    flr (i, 1, n) p[i] = i;
    
    dfs(1, -1);
    tarjan(1);
    
    flr (i, 0, m - 1) out(res[i]), pn;
    
    return 0;
}